﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using FOModels.BannerSlideShow;
using DataAccess.BannerSlideShow;
namespace Bussiness.BannerSlideShow
{
    public class BannerSlideShowBLL
    {
        private BannerSlideShowDAL dal;
        public BannerSlideShowBLL()
        {
            dal = new BannerSlideShowDAL();
        }
        public List<BannerSlideShowModels> getBannerSlideShow()
        {
            List<BannerSlideShowModels> list = new List<BannerSlideShowModels>();
            BannerSlideShowModels fur;
            DataTable tb = dal.getslideshow();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BannerSlideShowModels();
                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable =bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<BannerSlideShowModels> getBannerSlideShowAll()
        {
            List<BannerSlideShowModels> list = new List<BannerSlideShowModels>();
            BannerSlideShowModels fur;
            DataTable tb = dal.getslideshowall();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BannerSlideShowModels();
                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable = bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public BannerSlideShowModels getslideshowbyid(int SShowID)
        {

            BannerSlideShowModels fur = new BannerSlideShowModels();
            DataTable tb = dal.getslideshowbyid(SShowID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable = bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());

                }
                return fur;
            }
            else
            {
                return null;
            }
          
        }
        public int InsertSlide(BannerSlideShowModels models)
        {
            if (dal.InsertSlide(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateSlide(BannerSlideShowModels models)
        {
            if (dal.UpdateSlide(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteSlide(int SShowID)
        {
            if (dal.DeleteSlide(SShowID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        //EN

        public List<BannerSlideShowModels> getBannerSlideShow_EN()
        {
            List<BannerSlideShowModels> list = new List<BannerSlideShowModels>();
            BannerSlideShowModels fur;
            DataTable tb = dal.getslideshow_EN();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BannerSlideShowModels();
                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable = bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<BannerSlideShowModels> getBannerSlideShowAll_EN()
        {
            List<BannerSlideShowModels> list = new List<BannerSlideShowModels>();
            BannerSlideShowModels fur;
            DataTable tb = dal.getslideshowall_EN();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new BannerSlideShowModels();
                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable = bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public BannerSlideShowModels getslideshowbyid_EN(int SShowID)
        {

            BannerSlideShowModels fur = new BannerSlideShowModels();
            DataTable tb = dal.getslideshowbyid_EN(SShowID);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {

                    fur.SShowID = int.Parse(row[0].ToString());
                    fur.Title = row[1].ToString();
                    fur.Images = row[2].ToString();
                    fur.Target = row[3].ToString();
                    fur.Links = row[4].ToString();
                    fur.Enable = bool.Parse(row[5].ToString());
                    fur.OrderSort = int.Parse(row[6].ToString());

                }
                return fur;
            }
            else
            {
                return null;
            }

        }
        public int InsertSlide_EN(BannerSlideShowModels models)
        {
            if (dal.InsertSlide_EN(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int UpdateSlide_EN(BannerSlideShowModels models)
        {
            if (dal.UpdateSlide_EN(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int DeleteSlide_EN(int SShowID)
        {
            if (dal.DeleteSlide_EN(SShowID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }
}
